package org.example.bookingsystem.config;

import org.example.bookingsystem.common.Constants;
import org.springframework.amqp.core.*;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import static org.example.bookingsystem.common.Constants.*;

@Configuration
public class RabbitMQConfig {

    @Bean
    public Queue requestQueue() {
        return new Queue(REQUEST_QUEUE);
    }

    @Bean
    public Queue responseQueue() {
        return new Queue(RESPONSE_QUEUE);
    }

    @Bean
    public DirectExchange exchange() {
        return new DirectExchange("rpc.exchange");
    }

    @Bean
    public Binding requestBinding(Queue requestQueue, DirectExchange exchange) {
        return BindingBuilder.bind(requestQueue).to(exchange).with("request.routing.key");
    }

    @Bean
    public Binding responseBinding(Queue responseQueue, DirectExchange exchange) {
        return BindingBuilder.bind(responseQueue).to(exchange).with("response.routing.key");
    }
    @Bean
    public Queue requestQueue2() {
        return new Queue(REQUEST_QUEUE2);
    }

    @Bean
    public Queue responseQueue2() {
        return new Queue(RESPONSE_QUEUE2);
    }

    @Bean
    public DirectExchange exchange2() {
        return new DirectExchange("rpc.exchange2");
    }

    @Bean
    public Binding requestBinding2(Queue requestQueue2, DirectExchange exchange2) {
        return BindingBuilder.bind(requestQueue2).to(exchange2).with("request.routing.key2");
    }

    @Bean
    public Binding responseBinding2(Queue responseQueue2, DirectExchange exchange2) {
        return BindingBuilder.bind(responseQueue2).to(exchange2).with("response.routing.key2");
    }


}
